package com.nciae.controller;


import com.nciae.po.User;
import com.nciae.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Guoliyu
 * @since 2022-03-30
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    /**
     * 用户登录接口
     * @param username：用户名
     * @param password：密码
     * @return
     */
    @GetMapping("/login")
    public ResponseEntity<User> login(
            @RequestParam("username")String username,
            @RequestParam("password")String password
    ) {
        return ResponseEntity.ok(userService.login(username, password));
    }


    @PutMapping
    public ResponseEntity<Boolean> update(@RequestBody User user) {
        userService.updateById(user);
        return ResponseEntity.ok(true);
    }

}
